

#pragma once

#include "type.h"
#include "skill.h"
#include "talent.h"
#include "gameobject.h"

#define GDM			GameDataManager::getInstance()

class GameDataManager {
public:
	static GameDataManager* getInstance();
	~GameDataManager();
    
    void init();

private:
	static GameDataManager* _instance;
	GameDataManager();

	void loadUnitData();
	void loadAchievementData();
	void loadTalentData();

	void parseXmlNode(tinyxml2::XMLElement* xe, const char* tag, int& v);
	void parseXmlNode(tinyxml2::XMLElement* xe, const char* tag, float& v);
	void parseXmlNode(tinyxml2::XMLElement* xe, const char* tag, string& v);

	SkillType parseSkillType(const char* s);
	void parseGameObjectAttribute(tinyxml2::XMLElement* xe, GameObjectAttribute& attr);

public:
	map<string, AchievementInfo> achievements;
	map<string, GameObjectAttribute> unitsAttribute;
	map<string, TalentItem> talentsAttribute;
	

	int money;
	string playerName;
	string deviceID;
};

